<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);

include_once '../Api.php';

try
{
	$config = new \Namecheap\Config();
	$config->apiUser('api-username')
		->apiKey('api-key')
		->clientIp('your-ip')
		->sandbox(true);

	$command = Namecheap\Api::factory($config, 'domains.check');
	$command->domainList(array('example1.com', 'example2.me', 'acdealjfe.com'))->dispatch();
} catch (\Exception $e) {
	die($e->getMessage());
}

// Check single domain
echo 'example1.com ';
echo ($command->isAvailable('example1.com') === true) ? ' available' : ' not available';
echo "<br/>\n";

// Throws exception
echo 'billybob.com';
echo ($command->isAvailable('billybob.com') === true) ? ' available' : ' not available';
echo "<br/>\n";

foreach ($command->domains as $domain => $available):
	echo $domain;
	echo ($available === true) ? ' available' : ' not available';
	echo "<br/>\n";
endforeach;

function d($value = array())
{
	echo '<pre>' . "\n";
	print_r($value);
	die('</pre>' . "\n");
}
